#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<functional>
#include<queue>
#include<stack>
#include<list>
using namespace std;

int main(){
    // 输入：people = [[7,0],[4,4],[7,1],[5,0],[6,1],[5,2]]
    // 输出：[[5,0],[7,0],[5,2],[6,1],[4,4],[7,1]]
    vector <vector <int>> people ={{7,0},{4,4},{7,1},{5,0},{6,1},{5,2}};
    int n_size = people.size();
    // vector<vector <int>> result(n_size,vector<int> (2));
    vector<vector <int>> result;
    sort(people.begin(),people.end(), [](vector<int> a,vector<int> b){

        return (a[0]!=b[0])? (a[0]>b[0]):(a[1]<b[1]);
    } );
    // sort(people.begin(),people.end(),greater<vector<int>>());
    vector<int> temp;
    for(auto it =people.begin();it!=people.end();++it){
        temp = *it;
        // cout<<endl<< temp.front()<<endl<<"first:"<<temp[1];
        // cout<<"result.begin()"<<result.begin()<<endl;
        cout<<"(*it)[1]"<<(*it)[1]<<endl;
        result.insert(result.begin()+temp[1] , temp);
        // cout<<"result.size()"<<result.size()<<endl;
    }


    for(int i =0;i<people.size();++i){
        for(int j=0;j<people[0].size();++j){
            cout<<people[i][j]<<" ";
        }
        cout<<endl;
    }
    //排序是为了啥呢
    //怎样贪心呢
        /**
            该题采用贪心。前提：
            1.对元素排序：
                - 根据元素h进行从大到小排序
                - 根据元素k进行从小到大排序
            2.对排序后的元素进行贪心策略
        **/
    // for(int i=0;i<n_size;++i){
    //     // if(people[i][1]==)
    //     result[people[i][1]]=people[i];
    // }
    cout<<"result"<<endl;
    for(int i =0;i<people.size();++i){
        for(int j=0;j<people[0].size();++j){
            cout<<result[i][j]<<" ";
        }
        cout<<endl;
    }

    printf("love han");
    system("pause");
    return 0;
}